package namespace

import (
    "fcs-api/src/client/kubernetes"

    "git.inspur.com/x/common/loggerfactory"
    "k8s.io/api/core/v1"
    v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var logger = loggerfactory.GetLogger()

func CreateNamespace(fcClient *kubernetes.FcClient, namespace string) error {
    ns := &v1.Namespace{
        ObjectMeta: v12.ObjectMeta{
            Name: namespace,
            Labels: map[string]string{
                "eventing.knative.dev/injection": "enabled",
            },
        },
    }
    _, err := fcClient.CreateNamespace(ns)
    return err
}

func DeleteNamespace(fcClient *kubernetes.FcClient, namespace string) error {
    err := fcClient.DeleteNamespace(namespace)
    if err != nil {
        _ = logger.Error("Failed to Delete Namespaces: %s", err)
    }
    return err
}
